package com.xunji.standard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunji.standard.entity.TXjNdFlVoiceCall;
import com.xunji.standard.mapper.TXjNdFlVoiceCallMapper;
import com.xunji.standard.service.TXjNdFlVoiceCallService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @author Administrator
 * @description 针对表【t_xj_nd_fl_voice_call】的数据库操作Service实现
 * @createDate 2025-08-18 14:38:40
 */
@Service
public class TXjNdFlVoiceCallServiceImpl extends ServiceImpl<TXjNdFlVoiceCallMapper, TXjNdFlVoiceCall> implements TXjNdFlVoiceCallService {
    @Resource
    TXjNdFlPersonInformationServiceImpl txjNdFlPersonInformationService;

    @Override
    public List<TXjNdFlVoiceCall> selectListByCaseIdAndInfoId(String caseId, Long infoId, String xm, String sfzh) {
        List<String> lxfsedList = txjNdFlPersonInformationService.getlxfsList(caseId, infoId, xm, sfzh);
        if (lxfsedList == null || lxfsedList.isEmpty()) return null;
        QueryWrapper<TXjNdFlVoiceCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in("yhhm", lxfsedList);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public List<TXjNdFlVoiceCall> selectListByCaseIdAndXmAndSfzh(String caseId, List<String> lxhmList) {
        if (lxhmList == null || lxhmList.isEmpty()) return null;
        QueryWrapper<TXjNdFlVoiceCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in("yhhm", lxhmList);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public void deleteByCaseId(String caseId, String xm, String sfzh) {
        List<String> lxfsedList = txjNdFlPersonInformationService.getlxfsList(caseId, null, xm, sfzh);
        if (lxfsedList == null || lxfsedList.isEmpty()) return;
        QueryWrapper<TXjNdFlVoiceCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in("yhhm", lxfsedList);
        this.baseMapper.delete(qw);
    }

    @Override
    public List<TXjNdFlVoiceCall> selectListByCaseId(String caseId) {
        QueryWrapper<TXjNdFlVoiceCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId);
        return this.baseMapper.selectList(qw);
    }
}
